<?php

namespace App\Admin\Controllers;

use App\Models\Category;
use Encore\Admin\Form;
use Encore\Admin\Http\Controllers\AdminController;
use Encore\Admin\Table;

class CategoriesController extends AdminController
{
    protected $title = '分类管理';

    protected function table()
    {
        $table = new Table(new Category());

        $table->column('id', __('ID'));
        $table->column('name', __('名称'));
        $table->column('image', __('图片'))->image('', 50);
        $table->column('created_at', __('创建时间'));

        return $table;
    }

    protected function form()
    {
        $form = new Form(new Category());

        $form->text('name', __('名称'))->rules('required');
        $form->image('image', __('图片'))->help('建议图片尺寸：280px * 410px')->rules('required|image');
        $form->image('banner', __('Banner图'))->help('建议图片尺寸：1920px * 600px')->rules('required|image');
        $form->editor('body', __('内容'))->rules('required');

        return $form;
    }
}
